import json
#读取文件
def read_data(path):
    #打开文件
    with open(path,mode='r',encoding='utf-8') as f:
        #将JSON文件转为python类型
        data=json.load(f)
        # print(data_discuz)
        return data
# 写入文件
def write_data(list,path):
    with open(path,mode='w',encoding='utf-8') as f:   #打开文件赋予写入权限
        json.dump(list,f,ensure_ascii=False)    #将文件写到列表中

if __name__ == '__main__':
    path= r'amount.json'
    print(read_data(path))
    print(type(read_data(path)))
    # list=[{'时间': '2021/8/21 09:00:00', '项目': '工资', '分类': '收入', '金额': 20000},
    #       {'时间': '2021/8/21 09:00:00', '项目': '聚餐', '分类': '支出', '金额': -200}]
    # write_data(list,path)

